<template>
    <div>
        <el-form ref="form" :model="form" label-width="80px" style="width: 500px" >
            <el-form-item label="工程名称" >
            <el-input v-model="form.name" ></el-input>
            <!-- :disabled="true" -->
            
            
            
            

          </el-form-item >
          <el-form-item label="施工时间" >
            <el-col :span="11" >
              <el-date-picker type="date"  value-format="yyyy-MM-dd" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
            </el-col>

            <el-col class="line" :span="2">-------</el-col>

            <el-col :span="11" >
              <el-date-picker type="date"  value-format="yyyy-MM-dd" placeholder="选择日期" v-model="form.date2" style="width: 100%;" ></el-date-picker>
            </el-col> 
          </el-form-item>
          
            
          


                <el-form :label-position="labelPosition"  label-width="100px" :model="formLabelAlign" inline="true" label-position="left" >
                <el-form-item label="工程部位" style="width: 100px">
                    <el-input v-model="form.body"></el-input>
                </el-form-item>
                <el-form-item label="金额" style="width: 100px">
                    <el-input v-model="form.count"></el-input>
                </el-form-item>
                <el-form-item label="数量 " style="width: 100px">
                    <el-input v-model="form.length"></el-input>
                </el-form-item>
                <el-form-item label="浇筑方量" style="width: 100px">
                    <el-input v-model="form.size"></el-input>
                </el-form-item>
                
                



              
                  
                  <el-form-item>
                    <el-button type="primary" @click="onSubmit">更新</el-button>
                  </el-form-item>
                </el-form> 

        </el-form>

            

        </el-form>

    </div>
</template>




  <script>
    import gc from '@/api/gongcheng'
    export default {
      data() {
        return {
          form: {
            body:'',
            count:'',
            length:'',
            size:'',
            name: '',            
            date1: '',
            date2: '',
            id:''  ,                     
          },
          // id:''
          
        }
      },
      created(){
        //获取路由课程id值
        if(this.$route.params && this.$route.params.id) {
          this.id = this.$route.params.id
          console.log(this.id)
          //调用接口方法根据课程id查询
          this.getPublishId()
        }

      },


      methods: {
        getPublishId(){         
          gc.showId(this.id)
            .then(response =>{
              this.form=response.data.gongcheng
              console.log(this.form.id)
            })
        },
        onSubmit(){
            gc.update(this.form)
                .then(response =>{
                    this.form=response.data.gongcheng
                    console.log(this.form)
                })  
                //回到列表页面 路由跳转
                this.$router.push({path:'/gongcheng/show'})   
        }
      }
    }     
  </script>
